package com.gmail.gwanndan.common.hibernate;

import java.util.List;

/**
 * Interface for all Entities which are connected to persistence layer by
 * hibernate
 * 
 * @author Dennis Ahaus, dennis.ahaus@gmail.com
 * @version 1.0
 */
public interface IEntity {

	/**
	 * Get all entities of this type
	 * 
	 * @return
	 */
	<T> List<T> findAll();

	/**
	 * @param id
	 * @return
	 */
	<T> T findById(int id);

	/**
	 * Find an entity by property and value
	 * 
	 * @param <T>
	 * @param obj
	 * @param value
	 * @return
	 */
	<T> List<T> findBy(Object obj, Object value);

	/**
	 * @param obj
	 * @param value
	 * @return
	 */
	public <T> T findUniqueBy(Object obj, Object value);

	/**
	 * Save this Entity to persistence layer
	 * 
	 * @see javax.persistence.Persistence
	 * @author Dennis Ahaus
	 * @version 1.0, 10/29/11
	 */
	void save();

	/**
	 * Deletes this entity from persistence layer.
	 * 
	 * @author Dennis Ahaus
	 */
	void delete();

	/**
	 * Deletes all entities of this type in persistence layer
	 */
	void deleteAll();

	/**
	 * Get the unique identifier ( primary key ) for this entity
	 * 
	 * @return the unique iditifier
	 * 
	 * @author Dennis Ahaus
	 */
	int getId();

	/**
	 * Set the unique identifier ( primary key ) for this entity
	 * 
	 * @return the unique iditifier
	 * 
	 * @author Dennis Ahaus
	 */
	void setId(int id);

}
